package com.example.loginmodule;

import android.text.TextUtils;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.examination.mlib.constants.ARouterConstants;
import com.examination.mlib.constants.KitArouterConstants;
import com.examination.mlib.constants.UserInfoConstants;
import com.example.loginmodule.utils.LoginUtils;
import com.examination.mlib.baseold.ModuleBaseActivity;
import com.yilijk.base.utils.SharedPreferencesUtils;

@Route(path = ARouterConstants.CenterActivity)
public class CenterActivity extends ModuleBaseActivity {


    @Autowired
    public boolean isLogout = false;

    @Override
    public int bondLayout() {
        return R.layout.activity_center;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
//        SharedPreferencesUtils.getInstance().save("token","eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMzA1NTgyMzM0NzcxMjEiLCJ0eXBlIjoyfQ.AubGGEszuAOytuU0qgUYva3OgZnwCaI_gXLcvFMWXe4");
//        SharedPreferencesUtils.getInstance().save("token","eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxNTg4MjkyMTgzNjU0NDEiLCJ0eXBlIjoyfQ.1SaClXHzH53kSJUTsnV-uzmNF_UEHMFmGTQUDXrqo2w");
//        SharedPreferencesUtils.getInstance().save("token","eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxNDQ4NDMwMjIyNzA0NjUiLCJ0eXBlIjoyfQ.aajNicJA4wkq1Gc3h2Le1Grs4MMqCUffj2uN_NkH3rg");
//        SharedPreferencesUtils.getInstance().save("token","eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMzEyNjgxNjM0NjkzMTMiLCJ0eXBlIjoyfQ.mB8FzqTyFG5IGXYQRuWc5RUUB2_e4BPImzWpNgYQ4Bw");
//        SharedPreferencesUtils.getInstance().save("token","eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxNTkxNTk1MDUyNTY0NDkiLCJ0eXBlIjoyfQ.e3ZQ1L2PnWtIhrflus8X5oAk9T30H2xWJsA9mHiAaRc");
        String token = SharedPreferencesUtils.getInstance().getString(UserInfoConstants.token, null);
        String mobile = SharedPreferencesUtils.getInstance().getString(UserInfoConstants.account_mobile, null);
        if (TextUtils.isEmpty(token) || TextUtils.isEmpty(mobile)){
            LoginUtils.push(this, KitArouterConstants.LOGIN_DOCTORBUNDLE,KitArouterConstants.Login.Index);
        }else{
            ARouter.getInstance().build(ARouterConstants.MAIN_ACTIVITY).navigation();
            finish();
        }
//        finish();
    }



    @Override
    protected void onRestart() {
        super.onRestart();
        String token = SharedPreferencesUtils.getInstance().getString(UserInfoConstants.token, null);
        String mobile = SharedPreferencesUtils.getInstance().getString(UserInfoConstants.account_mobile, null);
        if (TextUtils.isEmpty(token) || TextUtils.isEmpty(mobile)){
            if (isLogout){
                LoginUtils.push(this, KitArouterConstants.LOGIN_DOCTORBUNDLE,KitArouterConstants.Login.Index);
            }else{
                finish();
            }
        }else{
            ARouter.getInstance().build(ARouterConstants.MAIN_ACTIVITY).navigation();
        }
        finish();
    }

    @Override
    public void initEvent() {

    }
}